package org.deadline.service.baseapp;

import java.util.List;
import org.deadline.model.baseapp.CommunicationChannel;
import org.deadline.repository.baseapp.CommunicationChannelRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class CommunicationChannelServiceImpl implements CommunicationChannelService {

	@Autowired
    CommunicationChannelRepository communicationChannelRepository;

	public long countAllCommunicationChannels() {
        return communicationChannelRepository.count();
    }

	public void deleteCommunicationChannel(CommunicationChannel communicationChannel) {
        communicationChannelRepository.delete(communicationChannel);
    }

	public CommunicationChannel findCommunicationChannel(Long id) {
        return communicationChannelRepository.findOne(id);
    }

	public List<CommunicationChannel> findAllCommunicationChannels() {
        return communicationChannelRepository.findAll();
    }

	public List<CommunicationChannel> findCommunicationChannelEntries(int firstResult, int maxResults) {
        return communicationChannelRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveCommunicationChannel(CommunicationChannel communicationChannel) {
        communicationChannelRepository.save(communicationChannel);
    }

	public CommunicationChannel updateCommunicationChannel(CommunicationChannel communicationChannel) {
        return communicationChannelRepository.save(communicationChannel);
    }
}
